﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Reflection;

using TRPOP.Common;
using TRPOP.CMS.Model;

namespace TRPOP.CMS.DALFactory
{
    public interface IContentUpFileDAL
    {

        ///	<summary>
        ///	保存
        ///	</summary>
        ///	<param name="ContentUpFileInfo"></param>
        ///	<returns>EnumSubmitResult</returns>
        EnumSubmitResult Save(ContentUpFileInfo info);

        ///	<summary>
        ///	获取实体
        ///	</summary>
        ///	<param name="contentUpFileId"></param>
        ///	<returns>ContentUpFileInfo</returns>
        ContentUpFileInfo GetInfoById(int id);

        ///	<summary>
        ///	删除
        ///	</summary>
        ///	<param name="id"></param>
        ///	<returns>EnumSubmitResult</returns>
        EnumSubmitResult DeleteInfoById(int id);

        ///	<summary>
        ///	删除
        ///	</summary>
        ///	<param name="ids"></param>
        ///	<returns>EnumSubmitResult</returns>
        EnumSubmitResult DeleteInfoByIds(string ids);

        ///	<summary>
        ///	自定义列表（无分页）
        ///	</summary>
        ///	<param name="topn">前N条，为0时表示所有符合条件的</param>
        ///	<param name="condition">自定义条件，要以And开头</param>
        ///	<param name="orderby">排序，不需要Order by </param>
        ///	<returns>List<ContentUpFileInfo></returns>
        List<ContentUpFileInfo> GetListByCondition(int topn, string condition, string orderby);
        /// <summary>
        /// 获取datatable
        /// </summary>
        /// <param name="topn"></param>
        /// <param name="strColumns"></param>
        /// <param name="condition"></param>
        /// <param name="orderby"></param>
        /// <returns></returns>
        DataTable GetDtListByCondition(int topn, string strColumns, string condition, string orderby);

        ///	<summary>
        ///	自定义列表（分页）
        ///	</summary>
        ///	<returns>List<ContentUpFileInfo></returns>
        List<ContentUpFileInfo> GetListByPager(int pageNumber, int pageSize, string condition, string orderby, out int recordCount);

        /// <summary>
        /// 通过路径获取实体
        /// </summary>
        /// <param name="FileRoot"></param>
        /// <returns></returns>
        ContentUpFileInfo GetInfoByFileRoot(string FileRoot);

        /// <summary>
        /// 通过ContentId删除附件
        /// </summary>
        /// <param name="ContentIds"></param>
        /// <returns></returns>
        EnumSubmitResult DeleteInfoByContentIds(string ContentIds);

        /// <summary>
        /// 通过NodeId删除附件
        /// </summary>
        /// <param name="NodeId"></param>
        /// <returns></returns>
        EnumSubmitResult DeleteInfoByNodeId(int NodeId);
        /// <summary>
        /// 更新某个结点下所有的fileurl
        /// </summary>
        /// <param name="intNodeID"></param>
        /// <param name="strRoot"></param>
        /// <param name="strUrlReplace"></param>
        /// <returns></returns>
        EnumSubmitResult UpdateFileURL(int intNodeID, string strRoot, string strUrlReplace);
    }


    public sealed partial class DataAccess
    {
        public static IContentUpFileDAL CreateContentUpFileDAL()
        {
            string className = path + ".ContentUpFileDAL";
            return (IContentUpFileDAL)Assembly.Load(path).CreateInstance(className);
        }
    }
}
